package it.asvp.asvp_portal.data.entity.world_story;

import it.asvp.asvp_portal.asvp_util.enumerative.StoryType;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;
import it.asvp.asvp_portal.data.entity.member.Member;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@SuppressWarnings("serial")
@Entity
@Table(name = "world_story", catalog = "asvp_db")
public class WorldStory extends BaseEntity {

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "id_member", nullable = false)
  private Member            member;

  @Column(name = "story_type", nullable = false, length = 50)
  @Enumerated(EnumType.STRING)
  private StoryType         storyType;

  @Column(name = "title", nullable = false, length = 100)
  private String            title;

  @Column(name = "text", nullable = false, length = 2500)
  private String            text;

  @OneToMany(fetch = FetchType.LAZY, mappedBy = "worldStory")
  @Cascade({ CascadeType.ALL })
  private Set<StoryPicture> storyPictures = new HashSet<StoryPicture>(0);

  public WorldStory() {
  }

  public WorldStory(Member member, StoryType storyType, String title, String text, Date createdOn, Date lastUpdate, Set<StoryPicture> storyPictures) {
    this.member = member;
    this.storyType = storyType;
    this.title = title;
    this.text = text;
    this.createdOn = createdOn;
    this.lastUpdate = lastUpdate;
    this.storyPictures = storyPictures;
  }

  public Member getMember() {
    return this.member;
  }

  public void setMember(Member member) {
    this.member = member;
  }

  public StoryType getStoryType() {
    return this.storyType;
  }

  public void setStoryType(StoryType storyType) {
    this.storyType = storyType;
  }

  public String getTitle() {
    return this.title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getText() {
    return this.text;
  }

  public void setText(String text) {
    this.text = text;
  }

  public Set<StoryPicture> getStoryPictures() {
    return this.storyPictures;
  }

  public void setStoryPictures(Set<StoryPicture> storyPictures) {
    this.storyPictures = storyPictures;
  }

}
